import Request from './request';
import localCache from '@/utils/cache';
const BASE_URL = process.env.VUE_APP_BASE_URL;
const request = new Request({
  baseURL: BASE_URL,
  timeout: 1000,
  interceptors: {
    requestInterceptors: (config) => {
      //token
      const token = localCache.getCache('token');
      if (token) {
        config.headers.Authorization = `Bearer ${token}`;
      }
      return config;
    },
    requestInterceptorsCatch: (err) => {
      return err;
    },
    responseInterceptors: (res) => {
      return res;
    },
    responseInterceptorsCatch: (err) => {
      return err;
    }
  },
  showLoading: true
});
export default request;
